package com.lijin.batchsys.framework.dao.model;

import java.util.ArrayList;
import java.util.List;

import com.lijin.batchsys.framework.common.BatchSysConstants;

public class BatchInfo {

	private int id;
	private int batchNo;
	private String batchDesc;
	private String batchRunType;
	private String batchRunTmConfig;
	private String recSt;
	private List<JobInfo> jobList = new ArrayList<JobInfo>();
	private String runTypeToStr; //汉字显示批次的运行状态

	/**
	 * 为该批次添加一个任务
	 * 
	 * @param job
	 */
	public void addJob(JobInfo job) {
		jobList.add(job);
	}
	
	public int getJobNum() {
		return jobList == null ? 0 : jobList.size();
	}
	
	public int getStepNum() {
		int totalStepNum = 0;
		for (JobInfo job : jobList) {
			totalStepNum += job.getStepNum();
		}
		return totalStepNum;
	}
	
	public String getBatchDetail() {
		StringBuilder detail = new StringBuilder();
		for (JobInfo job : jobList) {
			detail.append("任务:" + job.getJobNo() + "-" + job.getJobDesc() + ",步骤数:" + job.getStepNum() + "\n");
		}
		return detail.toString();
	}
	
	public String getSummary() {
		return "[batch_no: " + batchNo + ", batch_desc:" + batchDesc + "]";
	}

	public int getBatchNo() {
		return batchNo;
	}
	
	public void setBatchNo(int batchNo) {
		this.batchNo = batchNo;
	}

	public List<JobInfo> getJobList() {
		return jobList;
	}
	
	public String getBatchRunType() {
		return batchRunType;
	}
	
	public void setBatchRunType(String batchRunType) {
		this.batchRunType = batchRunType;
	}

	public boolean isEnabled() {
		return BatchSysConstants.REC_VALID.equals(recSt);
	}

	public String getRunTypeToStr() {
		return runTypeToStr;
	}

	public void setRunTypeToStr(String runTypeToStr) {
		this.runTypeToStr = runTypeToStr;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getBatchDesc() {
		return batchDesc;
	}

	public void setBatchDesc(String batchDesc) {
		this.batchDesc = batchDesc;
	}

	public String getBatchRunTmConfig() {
		return batchRunTmConfig;
	}

	public void setBatchRunTmConfig(String batchRunTmConfig) {
		this.batchRunTmConfig = batchRunTmConfig;
	}

	public String getRecSt() {
		return recSt;
	}

	public void setRecSt(String recSt) {
		this.recSt = recSt;
	}
	
	
}
